<%@ page import="java.util.ArrayList" %>
<%@ page import="vo.Teacher" %>
<%@ page import="vo.Score" %>
<%@ page import="dao.ScoreDao" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="../resources/css/jquery-ui-1.10.4.custom.min.css">
  <script src="../resources/js/jquery-1.10.2.js"></script>
  <script src="../resources/js/jquery-ui-1.10.4.custom.min.js"></script>
  <title>main</title>
  <link href="../resources/css/default.css" rel="stylesheet"/>
</head>
<body>
<%
  Teacher teacher = (Teacher) session.getAttribute("info");
  int sumIndex = (int) session.getAttribute("sumIndex");
%>
<div id="page" class="container">
  <div id="header">
    <div id="logo">
      <img src="../userImg/<%=teacher.getId()%>.jpeg"/>
      <h1><%=teacher.getId()%></h1>
    </div>
    <div id="menu">
      <ul>
        <li><a href="personal.jsp">个人信息</a></li>
        <li><a href="../one_page_student">学生管理</a></li>
        <li><a href="../one_page_course">课程管理</a></li>
        <li><a href="../one_page_attendance?teacher_id=<%=teacher.getId()%>">出勤管理</a></li>
        <li class="current_page_item"><a href="../one_page_score">成绩管理</a></li>
        <li><a href="../one_page_tuition_records">学费管理</a></li>
        <li><a onclick="return confirm('确认退出?');" href="../exit">退出登录</a></li>
      </ul>
    </div>
  </div>
  <div id="main">
    <div class="top">
      <h2>学生成绩管理</h2>
      <hr/>
      <button class="btn-add">添加成绩</button>
    </div>
    <form method="post" action="../update_score" style="height: 525px; margin-top: 80px">
      <input type="button" class="btn-excel" style="float: left;margin-top: 8px" onclick="location.href='score_excel.jsp';" value="导出EXCEL">
      <input type="submit" class="btn-add" style="float: right;margin-bottom: 30px" value="修改">
      <div class="table" style="margin-top: 20px; height: 525px">
        <table id="table" width="800" frame="box" align="center">
          <tr>
            <th height="35">成绩序号</th>
            <th>课程名称</th>
            <th>课程分数</th>
            <th>分数标准</th>
            <th>学生学号</th>
          </tr>
          <%
            try {
              ScoreDao scoreDao = new ScoreDao();
              ArrayList<Score> list = scoreDao.findAll();
              for (Score s : list) {
          %>
          <tr>
            <td height="35"><%=s.getId()%></td>
            <td><input value="<%=s.getCourse_name()%>" name="course_name" class="table-input" style="width: 100px"></td>
            <td><input value="<%=s.getScore()%>" name="score" class="table-input" width="60"></td>
            <td><input value="<%=s.getLevel()%>" name="level" class="table-input" style="width: 100px"></td>
            <td><input value="<%=s.getStu_id()%>" name="stu_id" class="table-input" style="width: 100px"></td>
            <td><a class="btn-delete"
                   onclick="return confirm('确定要删除吗?');"
                   href=<%="'../delete_score?id=" + s.getId() + "'"%>>删除</a></td>
            <input value="<%=s.getId()%>" name="s_id" type="hidden">
          </tr>
          <%
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          %>
        </table>

      </div>
    </form>

    <%
      if (sumIndex > 1){
    %>
    <div id="index">
      <a href="../one_page_score?index=1">首页</a>
      <%
        for (int i = 1; i <= sumIndex; i++) {
      %>
      <a href="../one_page_score?index=<%=i%>">第<%=i%>页</a>
      <%
        }
      %>
      <a href="../one_page_score?index=<%=sumIndex%>">尾页</a>
    </div>
    <%
      }
    %>
  </div>
</div>

<div id="add-dialog" title="添加成绩信息">
  <form id="add-form" method="post">
    成绩序号:<input name="id" type="text"><br>
    课程名称:<input name="course_name" type="text"><br>
    课程分数:<input name="score" type="text"><br>
    分数标准:<input name="level" type="text"><br>
    学生学号:<input name="stu_id" type="text"><br>
    <hr>
    <input style="float: right" type="submit" value="取消" onclick="function x() {
          $('#add-dialog').dialog('close');
        }">
    <input style="float: right; margin-right: 25px" type="submit" value="确定"
           onclick="this.form.action='../add_score'">
  </form>
</div>

<style>
  .ui-dialog-titlebar-close {
    display: none
  }
</style>

<script>
  $('#add-dialog').dialog({
    width: 310,
    autoOpen: false,
    draggable: false,
    modal: true,
    resizable: false
  });
  $('.btn-add').click(function () {
    $('#add-dialog').dialog('open');
  });
</script>
</body>
</html>

